#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int myAtoi(string str)
    {
        int ret, bndry = INT_MAX / 10;
        int flag = 1, sign = 1, i = 0;
        if (str.size() == 0)
            return 0;
        while (str[i] == ' ')
        {
            if (++i == str.size())
                return 0;
        }
        if (str[i] == '-')
        {
            sign = -1;
            i++;
        }
        else if (str[i] == '+')
        {
            i++;
        }

        for (; i < str.size(); i++)
        {
            if (str[i] < '0' || str[i]>'9')
                break;
            if (ret > bndry || ret == bndry && str[i] > '7')
            {
                return sign == 1 ? INT_MAX : INT_MIN;
            }
            ret = ret * 10 + (str[i] - '0');
        }
        return ret * sign;

    }
};




class Solution {
public:
    string addStrings(string num1, string num2) {
        int n1 = num1.size() - 1;
        int n2 = num2.size() - 1;
        int a, b, sum, over = 0;
        string res = "";

        while (n1 >= 0 || n2 >= 0)
        {
            a = 0;
            b = 0;
            if (n1 >= 0)
            {
                a = num1[n1--] - '0';
            }
            if (n2 >= 0)
            {
                b = num2[n2--] - '0';
            }

            sum = a + b;
            if (over == 1) {
                sum++;
            }
            over = sum / 10;
            sum %= 10;
            char tmp = sum + '0';

            res += tmp;
        }

        if (over == 1)
        {
            res += "1";
        }

        reverse(res.begin(), res.end());

        return res;
    }
};




class Solution {
public:
    void reverseString(vector<char>& s) {
        reverse(s.begin(), s.end());
    }
};




class Solution {
public:
    int firstUniqChar(string s) {
        int arr[26] = { 0 };
        for (char ch : s)
        {
            int pos = ch - 'a';
            arr[pos]++;
        }
        for (int i = 0; i < s.size(); i++)
        {
            int pos = s[i] - 'a';
            if (arr[pos] == 1)
                return i;
        }
        return -1;
    }
};